package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysTourist;
import com.ruoyi.system.service.ISysTouristService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人流量统计Controller
 * 
 * @author ruoyi
 * @date 2020-10-12
 */
@Controller
@RequestMapping("/system/tourist")
public class SysTouristController extends BaseController
{
    private String prefix = "system/tourist";

    @Autowired
    private ISysTouristService sysTouristService;

    @RequiresPermissions("system:tourist:view")
    @GetMapping()
    public String tourist()
    {
        return prefix + "/tourist";
    }

    /**
     * 查询人流量统计列表
     */
    @RequiresPermissions("system:tourist:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysTourist sysTourist)
    {
        startPage();
        List<SysTourist> list = sysTouristService.selectSysTouristList(sysTourist);
        return getDataTable(list);
    }

    /**
     * 导出人流量统计列表
     */
    @RequiresPermissions("system:tourist:export")
    @Log(title = "人流量统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysTourist sysTourist)
    {
        List<SysTourist> list = sysTouristService.selectSysTouristList(sysTourist);
        ExcelUtil<SysTourist> util = new ExcelUtil<SysTourist>(SysTourist.class);
        return util.exportExcel(list, "tourist");
    }

    /**
     * 新增人流量统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存人流量统计
     */
    @RequiresPermissions("system:tourist:add")
    @Log(title = "人流量统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysTourist sysTourist)
    {
        return toAjax(sysTouristService.insertSysTourist(sysTourist));
    }

    /**
     * 修改人流量统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysTourist sysTourist = sysTouristService.selectSysTouristById(id);
        mmap.put("sysTourist", sysTourist);
        return prefix + "/edit";
    }

    /**
     * 修改保存人流量统计
     */
    @RequiresPermissions("system:tourist:edit")
    @Log(title = "人流量统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysTourist sysTourist)
    {
        return toAjax(sysTouristService.updateSysTourist(sysTourist));
    }

    /**
     * 删除人流量统计
     */
    @RequiresPermissions("system:tourist:remove")
    @Log(title = "人流量统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysTouristService.deleteSysTouristByIds(ids));
    }
}
